const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
    mode: 'development',
    entry: './src/index.jsx',
    output: {
        filename: 'bundle.[hash].js',
        path: path.resolve(__dirname, 'dist')
    },
    resolve: {
        extensions: ['.jsx', '...']
    },
    module: {
        rules: [
            {
                test: /\.jsx$/,
                use:
                {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-react', '@babel/preset-env']
                    }
                }
            },
            {
                test: /\.module\.(css|less)/,
                use: [MiniCssExtractPlugin.loader, { loader: "css-loader", options: { modules: true } }],
            },
            {
                test: /\.css$/,
                exclude: [/\.module\.(css|less)/, /\.global\.less$/],
                use: ['style-loader', 'css-loader']
            }
        ]
    },
    plugins: [
        new MiniCssExtractPlugin(),
        new HtmlWebpackPlugin({
            template: './public/index.html'
        })

    ]

};
